package com.draemon.haixiawenti.constant;

import com.draemon.haixiawenti.repository.B_base_configRepository;
import com.yangzcp.userpojo.B_base_config;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Component
public class InitConstantService implements InitializingBean{
	
	public static String APP_SERVICE_HOST = "请设置：应用服务器域名";

	public static String ADMIN_SERVICE_HOST = "请设置：后台服务器域名";

	@Autowired
	private B_base_configRepository b_base_configRepository;

	public void afterPropertiesSet() throws Exception {
		List<B_base_config> b_base_config =	(List<B_base_config>) b_base_configRepository.findAll();
		if(!CollectionUtils.isEmpty(b_base_config)){
			APP_SERVICE_HOST =b_base_config.get(0).getApp_service_host();
			ADMIN_SERVICE_HOST =b_base_config.get(0).getAdmin_service_host();
		}
	}

}
